﻿Imports System.Windows.Forms


Public Class UbahPasswordPage
    Inherits baseForm

    Private Sub btnSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSimpan.Click
        Dim dt As New DataTable
        If TextPasswordLama.Text = "" Or TextPasswordBaru.Text = "" Or TextKonfirmasi.Text = "" Then
            MessageBox.Show("Masukan data tidak lengkap", "Gagal", MessageBoxButtons.OK)
        Else
            If Utils.executeSP("getlogin", New Object() {Session.username, TextPasswordLama.Text}, dt) Then
                If dt.Rows().Count > 0 Then
                    If TextPasswordBaru.Text = TextKonfirmasi.Text Then
                        If Utils.executeSP("proc_z_setuser", New Object() {"editpass", Session.username, TextPasswordBaru.Text, "0", "0"}, dt) Then
                            Utils.MessageFromDT(dt)
                        End If
                    Else
                        MessageBox.Show("Password tidak sama, silahkan coba lagi.")
                    End If
                Else
                    MessageBox.Show("Password lama yang dimasukan salah", "Gagal", MessageBoxButtons.OK)
                End If
            End If
        End If
    End Sub

    Private Sub UbahPasswordPage_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For Each c As Control In Panel2.Controls
            If TypeOf c Is TextBox Then
                c.Text = ""
            End If
        Next
    End Sub
End Class
